from django.db import models

# Create your models here.
# 商家账号
class BusinessAccountNumber(models.Model):
    account = models.CharField(verbose_name="账号", max_length=13, unique=True)
    password_md5 = models.CharField(verbose_name="加密密码", max_length=32)
    exist = models.BooleanField(verbose_name="是否激活", default=False)

    def __str__(self):
        return "账号：" + self.account


# 密码
class BusinessPassword(models.Model):
    password = models.CharField(verbose_name="密码", max_length=16)
    password_md5 = models.CharField(verbose_name="加密密码", max_length=32)

    bid = models.OneToOneField(BusinessAccountNumber, on_delete=models.CASCADE)


# 商家信息
class BusinessInformation(models.Model):
    business_name = models.CharField(verbose_name="商家名", max_length=64)
    grade = models.IntegerField(verbose_name="信用分", default=5)
    address = models.CharField(verbose_name="地址", max_length=200)
    bid = models.OneToOneField(BusinessAccountNumber, on_delete=models.CASCADE)

    def __str__(self):
        return "商家名： " + self.business_name